import 'package:favourcate/core/extension/int_fit_ext.dart';
import 'package:favourcate/ui/pages/filter/filter.dart';
import 'package:flutter/material.dart';

class GLHomeDrawer extends StatelessWidget {
  const GLHomeDrawer({ Key? key }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 250.px,
      child: Drawer(
        child: Column(
          children: [
            buildHeaderView (context),
            buildListTile(
              context,
              const Icon(Icons.restaurant, color: Colors.black,),
              '进餐',
              () {
                Navigator.of(context).pop();  /// 取消 drawer
              }
            ),
            buildListTile(
              context,
              const Icon(Icons.settings, color: Colors.black),
              '过滤',
              () {
                Navigator.of(context).pushNamed(GLFilterScreen.routeName);
              }
            ) 
          ],
        ),
      )
    );
  }

  Widget buildHeaderView (context) {
    return  Container(
      width: double.infinity,
      height: 150.px,
      color: Colors.orange,
      alignment: const Alignment(0, 0.5),
      margin: EdgeInsets.only(bottom: 20.px),
      child: Text('开始动手', style: Theme.of(context).textTheme.headline3!.copyWith(
        fontWeight: FontWeight.bold
      ),),
    );
  }

  Widget buildListTile(context, Widget icon, String title, handler) {
    return ListTile(
      leading: icon,
      title: Text(title, style: Theme.of(context).textTheme.headline2!.copyWith(
        color: Colors.black
      ),),
      onTap: handler,
    );
  }
}